﻿/*
 * Copyright 2012 Rene Prost, Registrite ja Infosüsteemide Keskus 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

using System;

namespace Xtee.Core.Envelope
{
   
    public class Fault
    {
        
        private String @__faultcode;
        
        private String @__faultstring;
        
        private String @__faultactor;
        
        private object _detail;
        
        public Fault() {
        }

        public override string ToString()
        {
            return
                string.Format("Code: {0}\r\nFaultString: {1}\r\nDetail: {2}\r\nActor: {3}\r\n", @__faultcode, @__faultstring,
                              _detail, @__faultactor);
        }
        public Fault(Exception e,Uri actor):this(e.GetType().Name,e.Message,actor == null ? string.Empty : actor.ToString(),e.ToString())
        { 
        }
        /// <summary>
        /// All parameters
        /// </summary>
        public Fault(String @faultcode, String @faultstring, String @faultactor, String detail) {
            this.@__faultcode = @faultcode;
            this.@__faultstring = @faultstring;
            this.@__faultactor = @faultactor;
            this._detail = detail;
        }
        
        /// <summary>
        /// Copy Constructor
        /// </summary>
        protected Fault(Fault @fault) {
            this.@__faultcode = @fault.Faultcode;
            this.@__faultstring = @fault.Faultstring;
            this.@__faultactor = @fault.Faultactor;
            this._detail = @fault.Detail;
        }
        
        public virtual String Faultcode {
            get {
                return this.@__faultcode;
            }
            set {
                this.@__faultcode = value;
            }
        }
        
        public virtual String Faultstring {
            get {
                return this.@__faultstring;
            }
            set {
                this.@__faultstring = value;
            }
        }
        
        public virtual String Faultactor {
            get {
                return this.@__faultactor;
            }
            set {
                this.@__faultactor = value;
            }
        }
        
        public virtual object Detail {
            get {
                return this._detail;
            }
            set {
                this._detail = value;
            }
        }
    }
}